$(function () {
    var operating = null;

    var errorHandler = function (error) {
        $('#submitAdd').tip({content:error.responseJSON.info,background:"#000",color:"#fff"});
    };

    // 添加分销渠道
    $('#submitAdd').on('click', function () {
        var name = $('#addName').val().trim(),
            reg = window.commonRegexp.nameLength15;
        if (!reg.test(name)) {
            $(this).tip({content:lang('hotel.payStyle'),background:"#000",color:"#fff"});
            return false;
        }

        var param = {
                hotel: window.currentHotel,
                name: name
            },
            $me = $(this);
        $('#addName').val("");
        ajaxRequest('/Home/Hotel/addChannel', param, 'post', null, errorHandler, $me);
    });
    // 删除分销渠道
    $('.deleteBtn').on('click', function (e) {
        operating = $(this).parents('.tag-item').data('value');
    });
    // 删除分销渠道model点击
    $('#submitDelete').on('click', function (e) {
        var param = {
                hotel: window.currentHotel,
                channel: operating
            },
            $me = $(this);
        ajaxRequest('/Home/Hotel/deleteChannel', param, 'post', null, null, $me);
    });
});

